package com.wanxi.test;
//猜数字游戏
import java.util.Scanner;

public class GuessGame {
    public static void main(String[] args) {
        int random = (int) (Math.random() * 100) + 1;
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入1到100的整数： ");
        int inputNumber = scanner.nextInt();
        int inputCount = 1;
        while (inputNumber != random) {
            if (inputNumber > random) {
                System.out.println("大了");
            } else if (inputNumber < random) {
                System.out.println("小了");
            }
            System.out.print("请输入1到100的整数： ");
            inputNumber = scanner.nextInt();
            inputCount++;
        }
        System.out.print("恭喜你猜对了");
        System.out.print("你猜的次数为： " + inputCount);
        scanner.close();
    }
}
